import request from "../lib/request";

// 海报生成
export async function generatePoster(data: {
  imageId: number;
  prompt: string;
}) {
  return request({
    url: "/image-generation/workflow",
    method: "POST",
    data,
  });
}

// 生成相似图片
export async function generateSimilarImage(data: {
  originalImageId?: number;
  count?: number;
  style?: string;
  customPrompt?: string;
  userId: number;
}) {
  return request({
    url: "/image-generation/generate",
    method: "POST",
    data,
  });
}

// 批量生成相似图片
export async function batchGenerateSimilarImages(data: {
  imageIds: number[];
  countPerImage?: number;
  style?: string;
  customPrompt?: string;
  userId: number;
}) {
  return request({
    url: "/image-generation/generate/batch",
    method: "POST",
    data,
  });
}

// 获取图片的生成记录
export async function getImageGenerationRecords(
  originalImageId: number,
  userId?: number
) {
  return request({
    url: `/image-generation/original/${originalImageId}`,
    method: "GET",
    params: userId ? { userId } : undefined,
  });
}

// 获取生成记录详情
export async function getGenerationRecordDetail(
  recordId: number,
  userId?: number
) {
  return request({
    url: `/image-generation/record/${recordId}`,
    method: "GET",
    params: userId ? { userId } : undefined,
  });
}

// 删除生成记录
export async function deleteGenerationRecord(
  recordId: number,
  userId?: number
) {
  return request({
    url: `/image-generation/record/${recordId}/delete`,
    method: "POST",
    params: userId ? { userId } : undefined,
  });
}

// 重试失败的图片生成
export async function retryFailedImageGenerations(userId?: number) {
  return request({
    url: "/image-generation/retry-failed",
    method: "POST",
    params: userId ? { userId } : undefined,
  });
}

// 获取图片生成统计信息
export async function getImageGenerationStatistics(userId?: number) {
  return request({
    url: "/image-generation/statistics",
    method: "GET",
    params: userId ? { userId } : undefined,
  });
}
